/*
 * @Author: jiayu
 * @Date: 2022-08-04 14:45:06
 * @LastEditors: jiayu
 * @LastEditTime: 2023-07-31 11:11:59
 * @Description:
 */
import { useOrganizationalStore } from '';
import { AppstoreOutlined, AreaChartOutlined, EditOutlined, MailOutlined, ReadOutlined, SettingOutlined } from '@ant-design/icons';
import { history, useLocation, useModel } from '@umijs/max';
import { Button, Drawer, Menu, MenuProps } from 'antd';
import { useMemo } from 'preact/hooks';
import { useEffect, useState } from 'react';
import DepTree from '../DetTree';
import styles from './index.less';
const HeaderContent = () => {
  const [showDeps, setShowDeps] = useState(false)
  const { currentPosi } = useModel('organizational')
  const [current, setCurrent] = useState('');
  const location = useLocation()
  useEffect(() => {
    if (location.pathname == '/front') {
      setCurrent('/front')
    } else if (location.pathname == '/manger') {
      setCurrent('/manger')
    } else {
      setCurrent('/welcome')
    }

  }, [])

  const items: MenuProps['items'] = [
    {
      label: '首页',
      key: '/welcome',
      icon: <AreaChartOutlined />,
    },
    {
      label: '学员首页',
      key: '/front',
      icon: <ReadOutlined />,
    },
    {
      label: '后台管理',
      key: '/manger',
      icon: <SettingOutlined />,
    },
  ]
  const onClick: MenuProps['onClick'] = e => {
    // history.push(e.key)
    // setCurrent(e.key);
    if (e.key == '/front') {
      window.open(window.home_url)
    }
    if (e.key == '/manger') {
      window.open(window.manger_url)
    }
  };
  return (
    <div className={styles.headerContent}>
      <Menu onClick={onClick} selectedKeys={[current]} mode="horizontal" items={items} />
      {/* <img className={styles.img} src={require('../../images/title.png')} alt="" />
      <div className={styles.changeGroup}>
        <div className={styles.currentGroup}>当前统计区域：{currentPosi.map(item => item.short_name).join(' /')}</div>
        <Button type="primary" icon={<EditOutlined />} onClick={() => setShowDeps(true)}>
          切换组织/机构
        </Button>
      </div>
      <Drawer
        width={600}
        visible={showDeps}
        onClose={() => {
          setShowDeps(false);
        }}
        closable={true}
        title="切换组织/机构"
      >
        <DepTree hide={() => setShowDeps(false)} />
      </Drawer> */}
    </div>
  );
};

export default HeaderContent;
